package net.hxz.modules.controller.frontEnd;

import net.hxz.modules.controller.BaseController;
import net.hxz.modules.services.INewsService;
import net.wy.myBatisPlugin.page.model.PageRowBounds;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 网站统一入口
 * @author OYJ
 */
@Controller
@RequestMapping(value="/news/")
public class NewsController extends BaseController {
	
	@Autowired
	private INewsService newsService;
	
	@RequestMapping("detail-{lang}")
	public String index(@PathVariable String lang, Long newsId, ModelMap map) {
		map.put("n", newsService.get(newsId));

		map.put("lang", lang.equals("en") ? 0 : 1);
		map.put("jsp", "news/detail");
		
		return PHONE_MAIN_PATH;
	}
	
	@RequestMapping("list-{lang}")
	public String index(@PathVariable String lang, ModelMap map, PageRowBounds page) {
		map.put("list", newsService.list(page));
		map.put("lang", lang.equals("en") ? 0 : 1);
		map.put("jsp", "news/list");
		map.put("page", page);
		
		return PHONE_MAIN_PATH;
	}
	
}
